// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'clude-9gs6bk1458f73c15'
})
const db=cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  var openid=event.openid;
  var task=event.task;
  var starttime=event.starttime;
  var endtime=event.endtime;
  db.collection("task").add({
    data:{
      _openid:openid,
      allperson:task.allperson,
      finshedperson:task.finshedperson,
      hid:"block",
      endtime:endtime,
      starttime:starttime,
      target:task.target,
      taskname:task.taskname,
      connection:[],
      userid:openid
    }
  })
  return event.starttime;
}